package com.authine.cloudpivot.ext.domain.impl;

import com.authine.cloudpivot.ext.conf.ApplicationConf;
import com.authine.cloudpivot.ext.util.BoServiceUtils;
import com.authine.cloudpivot.ext.util.MailUtil;
import com.authine.common.util.IdWorker;
import com.authine.mvp.app.launcher.dto.bo.response.BO;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;
import java.util.Objects;

/**
 * @program: gomro
 * @description:
 * @author: wlw
 * @create: 2021-09-18 15:13
 **/
@Slf4j
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SaveGoodsHistoryTask extends Thread {
    private String goodsId;
    @Override
    @SuppressWarnings("all")
    public void run() {
        BO data = BoServiceUtils.loadByBizObjectId(ApplicationConf.GOODES, goodsId).getData();
        Map<String, Object> goods = data.getData();
        if(Objects.isNull(data)||Objects.isNull(goods)){
            log.warn("【SaveGoodsHistoryTask】 query by goodsId is null :{}",goodsId);
            return;
        }
        goods.remove("createdBy");
        goods.remove("createdDept");
        goods.remove("createdTime");
        goods.remove("ownerDept");
        goods.remove("modifiedBy");
        goods.remove("modifiedTime");
        goods.remove("document");
        goods.remove("status");
        goods.put("goodses_id",goods.get("id"));
        goods.put("id", IdWorker.nextId());
    }
}
